<template>
	<view class="changePassword_contant">
		<view class="card contant">
			<view class="header">设置新密码</view>
			<view class="middle">
				<view class="Changepass flex">
					<view>新密码</view>
					<input class="phone-input" type="text" :password="ShowOrHide" v-model="form.passWord" placeholder="请设置新密码"/>
					<text class="iconfont show password" @tap="ShowOrHide = true" v-if="!ShowOrHide" style="top:0rpx;"></text>
					<text class="iconfont hide password" @tap="ShowOrHide = false " v-else style="top:0rpx;"></text>
				</view>
				<view class="Changepass flex">
					<view>确认密码</view>
					<input class="phone-input" type="text" :password="ShowOrHideTwo" v-model="form.aginPassWord" placeholder="请再次输入新密码"/>
					<text class="iconfont show password" @tap="ShowOrHideTwo = true" v-if="!ShowOrHideTwo" style="top:0rpx;"></text>
					<text class="iconfont hide password" @tap="ShowOrHideTwo = false" v-else style="top:0rpx;"></text>
				</view>
			</view>
			<view class="footer" @tap="sumbit">确认提交</view>
			<view class="desc">安全提示：字母符号组合安全性更高</view>
		</view>
	</view>
</template>

<script>
	import {
		updateMember
	} from '@/common/http/api.js'
	import { mapMutations } from 'vuex'
	export default {
		data() {
			return {
				form:{
					passWord: '',
					aginPassWord: ''
				},
				ShowOrHide:true,
				ShowOrHideTwo: true
			}
		},
		methods: {
			...mapMutations(['logout']),
			sumbit(){
				if(this.form.passWord.length < 6){
					this.$ut.msg('密码不能少于六位');
					return false;
				}
				if(this.form.passWord != this.form.aginPassWord){
					this.$ut.msg('两次输入的密码不一致');
					return false;
				}
				updateMember({type: 2,password: this.form.passWord}).then(res => {
					this.$ut.msg('修改成功，请重新登录!')
					setTimeout(()=>{
						uni.$u.route({
							url: 'pages_Me/login/login',
							type:'reLaunch'
						})
						this.logout()
					},1000)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.changePassword_contant{
		.contant{
			padding: 38rpx 60rpx;
		}
		.header{
			margin-bottom: 53rpx;
			font-family: Alibaba PuHuiTi, Alibaba PuHuiTi;
			font-weight: 700;
			font-size: 40rpx;
			color: #666666;
		}
		
		.middle{
			.Changepass{
				justify-content: flex-start;
				padding-bottom: 15rpx;
				border-bottom: 2rpx solid #f5f5f5;
				margin-bottom: 30rpx;
				position: relative;
				
				view{
					width: 120rpx;
					// height: 36rpx;
					font-size: 28rpx;
					color: #313131;
					margin-right: 20rpx;
				}
				
				input{
					font-size: 26rpx;
					padding: 0 10rpx;
					line-height: 30rpx;
					color:#666;
				}
				
				.placeholder{
					color: #d9d9d9;
				}
			}
		}
		
		.footer{
			width: 100%;
			height: 74rpx;
			background-color: #FF4D60;
			line-height: 74rpx;
			color: #fff;
			text-align: center;
			border-radius: 34rpx;
			margin-top: 40rpx;
			margin-bottom: 22rpx;
		}
		.desc{
			font-family: Alibaba PuHuiTi, Alibaba PuHuiTi;
			font-size: 22rpx;
			color: #666666;
		}
	}
</style>
